include("shared.lua")

-- include custom vgui files
include("vgui/custom/menu.lua")
include("vgui/custom/button.lua")
include("vgui/custom/closeButton.lua")
include("vgui/custom/spawnicon.lua")
include("vgui/custom/build.lua")
include("vgui/custom/cScoreboard.lua")
include("cl_buildmode.lua")

-- vector
myVec = {}


function OpenTurretInfo(um)

	if menu then menu:Remove() end
	
	menu = vgui.Create("cMenu") 
	
	-- setting size and pos relative to resolution
	local w, h = math.max(ScrW()/3, 640) , math.max(ScrH()/2.25, 400)
	local x, y = (ScrW() - w) / 2, (ScrH() - h) / 2
	
	-- getting turret info through usermessage
	local str = string.Explode("_",um:ReadString())		
	local level = um:ReadShort()
	local type, id = str[1]..tostring(level), str[2] 
	local turret = TURRETS.AllTurrets[type]
	
	menu:SetTurret(turret)
	menu:SetSize(w, h)
	menu:SetPos(x, y)
	menu:Register(w, h, x, y)
	
	menu:SetVisible(true)
		menu:AddButton("stats", 112, 36, "Statistics", "gui/nonsense/info")
		menu:AddButton("upgrade", 112, 36, "Upgrade","gui/nonsense/upgrade")
		menu:AddButton("", 112, 36, "Sell","")
		menu:AddButton("", 112, 36, "Exit","")		
end
usermessage.Hook("OpenTurretInfo", OpenTurretInfo)

score = vgui.Create("cScoreboard")
score:SetSize(800,600)
score:SetLogo("gui/joo/gDefense")
score:SetFont("Default")
score:Center()
score:SetVisible(false)

function GM:ScoreboardShow()
	score:SetVisible(true)
end

function GM:ScoreboardHide()
	score:SetVisible(false)
end